package com.chis.childcheck;

import com.chis.childcheck.JedisConnect;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.ShardedJedis;
import redis.clients.jedis.Tuple;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * 
 * @Description 
 * @Company zwx
 * @author wlj
 * @version 2019年08月21日
 */
public class ExcCount {
    public static void main(String[] args) {
        ShardedJedis jedis = JedisConnect.getInstance().sparkjedisPool.getResource();
        jedis.select(1);
        Set<String> fullKey = new HashSet<>();
        Iterator i$ = jedis.getAllShards().iterator();
        if (i$.hasNext()) {
            Jedis jei = (Jedis) i$.next();
            fullKey.addAll(jei.keys("*"));
        }
        for(String key : fullKey){
            jedis.select(0);
            String offset = jedis.get(key);
            jedis.select(1);
            Long value = jedis.zcount(key.getBytes(), 0, Integer.valueOf(offset)-1);
            System.out.println("=============================== key: "+key+"数量："+value);
        }
        jedis.close();

    }
}
